<template>
  <HomePanel ref="target" title="新鲜好物" sub-title="新鲜出炉 品质靠谱">
    <template #right>
      <xtx-more></xtx-more>
    </template>
    <template #default>
      <!-- <ul ref="pannel" class="goods-list-top">
        <li v-for="item in list" :key="item.id">
          <RouterLink :to="`/goods/${item.id}`">
            <img v-lazys="item.picture" :src="load" alt="" />
            <p class="name">{{ item.name }}</p>
            <p class="price">&yen;{{ item.price }}</p>
          </RouterLink>
        </li>
      </ul> -->
      <HotList :goods="list" />
    </template>
  </HomePanel>
</template>

<script>
import HomePanel from './home-panel'
import { findNew } from '@/api/home'
import { ref, getCurrentInstance } from 'vue'
import { useObserve } from '@/hooks'
import HotList from './home-hot-list.vue'

export default {
  components: {
    HomePanel,
    HotList
  },
  data () {
    return {
      meng: 100
    }
  },
  setup () {
    // 1.定义响应式数据
    const list = ref([])
    // 2.定义函数 函数内部调用接口函数
    async function getList () {
      const res = await findNew()
      list.value = res.result
      // console.log('data:', getCurrentInstance())
    }
    const { target } = useObserve(getList)
    console.log('获取当前组件实例：', getCurrentInstance())
    // 3. onMounted中调用getList
    // onMounted(() => {
    //   getList()
    // })
    return {
      list,
      target
    }
  }
}
</script>
